package android07.newtop.adapter;

import android.content.Context;
import android.view.ViewGroup;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;

import java.util.List;

import android07.newtop.holder.NewTopViewHolder;
import android07.newtop.holder.NowWeatherViewHolder;
import android07.newtop.holder.SuggestionViewHolder;
import android07.newtop.model.bean.WeatherInfoBean;


public class WeatherListAdapter extends RecyclerArrayAdapter<Object> {

    private Context mContext;

    private static final int Realtime = 0;
    private static final int Life = 1;
    private static final int Weather = 2;
    private static final int Pm = 3;


    public WeatherListAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        if (viewType == WeatherListAdapter.Realtime) {
            return new NowWeatherViewHolder(parent);
        }
        if (viewType == WeatherListAdapter.Life) {
            return new SuggestionViewHolder(parent);
        }
//        if (viewType == WeatherListAdapter.Weather) {
//            return new NewTopViewHolder(parent);
//        }
//        if (viewType == WeatherListAdapter.Pm) {
//            return new NewTopViewHolder(parent);
//        }
        return  null;
    }


    @Override
    public void OnBindViewHolder(BaseViewHolder holder, int position) {
        super.OnBindViewHolder(holder, position);
    }

    @Override
    public int getViewType(int position) {
        if(getItem(position) instanceof WeatherInfoBean.ResultBean.DataBean.RealtimeBean){

            return  Realtime;
        } else if(getItem(position) instanceof WeatherInfoBean.ResultBean.DataBean.LifeBean){
            return  Life;
        }
//        else if(getItem(position) instanceof WeatherInfoBean.ResultBean.DataBean.Pm25Bean){
//            return  Pm;
//        }else if(getItem(position) instanceof List){
//            return  Weather;
//        }
        return  -1;
    }
}
